package com.example.controller;

import com.example.config.AppConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class ConfigController {

    private static String hello;
    @Autowired
    AppConfig appConfig;

    public static String getHello() {
        return hello;
    }
    @Value("${hello:lily}")
    public void setHello(String hello) {
        ConfigController.hello = hello;
    }

    @RequestMapping("/hello")
    public String get() {
        return hello;
    }

    @RequestMapping("/name")
    public String get2() {
        return appConfig.getName();
    }
}
